const Mock = require('mockjs')
// 拓展mockjs
Mock.Random.extend({
	phone: function () {
	var phonePrefixs = ['132', '135', '189']
	return this.pick(phonePrefixs) + Mock.mock(/\d{8}/)
	}
})

const data = Mock.mock({
  'items|30': [{
    id: '@id',
    mobile: "@string('number',11)",
    name: '@cname',
    'state|1': ['在读', '已结课', '未结课'],
    school: '@city',
    display_time: '@datetime',
    pendCount: '@integer(1, 50)',
    doneCount: '@integer(1, 50)',
  }]
})

module.exports = [
  {
    url: '/api/student/get',
    type: 'get',
    response: config => {
      const items = data.items
      return {
        code: 200,
        data: {
          total: items.length,
          orders: items,
          records: items,
        },
		msg: 'success',
		success: true
      }
    }
  },
  {
    url: '/api/Students/selectIntrodStudent',
    type: 'get',
    response: config => {
		const data = Mock.mock({
			'items|30': [{
				id: '@id',
				studentName: '@cname',
				parentName: '@cname',
				parentPhone: '@phone',
				studentBirth: '@DATETIME("yyyy-MM-dd")',
				classLevel: () => {
					return ['小学一年级', '学期大班', '高中高二', '初中初三'][parseInt(Math.random() * 4)]
				}
			}]
		})
		const items = data.items
		return {
			code: 200,
			data: {
				total: items.length,
				orders: items,
				records: items,
			},
			msg: 'success',
			success: true
		}
    }
  },
  {
    url: '/api/Members/selectIntrodEmployee',
    type: 'get',
    response: config => {
		const data = Mock.mock({
			'items|30': [{
				id: '@id',
				memberName: '@cname',
				memberPhone: '@phone',
				'memberQuality|1': ['员工', '教师'],
			}]
		})
		const items = data.items
		return {
			code: 200,
			data: {
				total: items.length,
				orders: items,
				records: items,
			},
			msg: 'success',
			success: true
		}
    }
  }
]
